package Java8;

import java.util.Arrays;
import java.util.Comparator;
import java.util.List;
import java.util.Optional;
import java.util.function.Function;

public class Max_Min {
    public static void main(String[] args) {
        List<Track> list = Arrays.asList(new Track("baba", 401), new Track("aaa", 111), new Track("ccc", 211));
        Optional<Track> op = list.stream().min(Comparator.comparing(track -> track.getNumber()));
        Optional<Track> op2 = list.stream().max(Comparator.comparing(track -> track.getNumber()));
        System.out.println(op.get().getName());
        System.out.println(op2.get().getName());
        Function<Integer, String[]> fun = String[]::new;
        String[] str = fun.apply(2);
        System.out.println(Arrays.asList(str));
    }

    static class Track {
        private String name;
        private int number;

        public Track(String name, int number) {
            this.name = name;
            this.number = number;
        }

        public String getName() {
            return name;
        }

        public void setName(String name) {
            this.name = name;
        }

        public int getNumber() {
            return number;
        }

        public void setNumber(int number) {
            this.number = number;
        }

    }
}
